<?php
namespace Admin\Controller;
use Think\Controller;
//用户模块
class UserController extends Controller {
    public function index(){
        // //显示用户模板
        $user = D('user');

        $name = I('post.name');
        //做是否搜索判断，若是 则执行搜索方法
        if($name){
            $list = $user->user_ssel();
        }else{
          $list = $user->user_sel();  
        }
        
        //分配数据
        $this->assign('list',$list['list']);
        $this->assign('show',$list['show']);
        // dump($list);
        $this->display();
    }
    //禁用用户方法
    public function user_j(){
        $user = D('user');
        $res = $user->user_jj();
        echo $res;
    }
    //启用用户方法
    public function user_q(){
        $user = D('user');
        $res = $user->user_qq();
        echo $res;
    }
    //展示添加用户页面
    public function adduser(){
        $this->display(); 
    }
    //删除用户方法
    public function user_del(){
        $user = D('user');
        $res = $user->del_user();
        echo $res;
    }
   //展示用户详细信息
    public function show(){
        $info = M('user_info');
        $id = I('get.id');
        $map['uid'] = ['eq',$id];
        $list = $info->where($map)->select();
        $sex = ['1'=>'男','2'=>'女'];
        $grade = ['1'=>'青铜会员','2'=>'白银会员','3'=>'黄金会员','4'=>'铂金会员','5'=>'钻石会员'];
        foreach($list as $key => &$val){
            $val['sex'] = $sex[$val['sex']];
            $val['grade'] = $grade[$val['grade']];
        }
        $this->assign('val',$list[0]);
        $this->display();
    }
}